﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zocono.Infrastructure.Common
{
    public class CreateTaskCode
    {
        private static object obj = new object();
        public static long GetTaskCode()
        {
            lock (obj)
            {
                string date = DateTime.Now.ToString("yyyyMMdd");
                long runningNum = Convert.ToInt64(JsonConfigurationHelper.GetJson("appsettings.json", "TaskCode"));
                runningNum++;
                if (runningNum >= 900000)
                {
                    runningNum = 1;
                }
                JsonConfigurationHelper.SetJson("appsettings.json", "TaskCode", runningNum.ToString());
                return Convert.ToInt64(date + string.Format("{0:000000}", runningNum));
            }
        }


    }
}
